package controllers.administrator;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import services.AuctionService;
import controllers.AbstractController;
import domain.Auction;

@Controller
@RequestMapping("/auction/administrator")
public class AuctionAdministratorController extends AbstractController{
	// Services
	@Autowired
	private AuctionService auctionService;

	// Constructor
	public AuctionAdministratorController() {
		super();
	}

	// Listing methods
	@RequestMapping(value = "/finishedList", method = RequestMethod.GET)
	public ModelAndView list() {
		ModelAndView result;
		Collection<Auction> auctions;

		auctions = auctionService.findFinishedAuctions();

		result = new ModelAndView("auction/finishedList");
		result.addObject("requestURI", "auction/administrator/finishedList.do");
		result.addObject("auctions", auctions);
		result.addObject("backURI", "/welcome/index.do");
		return result;
	}

}
